require.config({
  baseUrl: "./script/",
  paths: {
    // three: 'script/../../../lib/three'
    stats: '../../lib/stats.min'
  },
  shim: {
    'script/../../../lib/three': {
      exports: 'THREE'
    }
  }
})

require(['stats', 'script/../../../lib/three'], function (Stats, THREE) {

  let scene = null
  let camera = null;
  let renderer = null;

  let mesh = null;
  let id = null;

  init()
  function init() {
    // 渲染器
    renderer = new THREE.WebGLRenderer();
    renderer.setSize(400, 300);
    document.body.appendChild(renderer.domElement);
    renderer.setClearColor(0x000000);
    scene = new THREE.Scene()

    camera = new THREE.OrthographicCamera(-5, 5, 3.75, -3.75, 0.1, 100);
    camera.position.set(5, 5, 20);
    camera.lookAt(new THREE.Vector3(0, 0, 0));
    scene.add(camera);

    mesh = new THREE.Mesh(new THREE.CubeGeometry(1, 2, 3),
      new THREE.MeshLambertMaterial({
        color: 0xffff00
      }));
    scene.add(mesh);

    const light = new THREE.DirectionalLight(0xffffff)
    light.position.set(20, 10, 5);
    scene.add(light);

    id = setInterval(draw, 20);
  }

  function draw() {
    mesh.rotation.y = (mesh.rotation.y + 0.01) % (Math.PI * 2);
    renderer.render(scene, camera);
  }

  function stop() {
    if (id !== null) {
      clearInterval(id);
      id = null;
    }
  }

  window.stop = stop
})